﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using WoodRobotics.Weather.ModelView;
using System.Collections.ObjectModel;

namespace WoodRobotics.Weather.ViewModel
{
    
    public class AstronomyEvents
    {
        
        #region Constructor
        public AstronomyEvents()
        {
            
            Events = new ObservableCollection<AstronomyEvent>();
            
            Events.Add(new AstronomyEvent()
            {
                Description = "The planet Mercury will be far enough from the Sun's glare to be visible shortly after sunset. Mercury will reach greatest elongation from the Sun on March 5, reaching a relatively bright magnitude of about -1. This will be your best chance to see the planet this year.",
                Start = new DateTime(2012,2,20),
                End = new DateTime(2012,3,12),
                Type = EventType.PlanetaryEvent
            });
            
            Events.Add(new AstronomyEvent()
            {
                Description = "The Moon will be directly between the Earth and the Sun and will not be visible from Earth. This phase occurs at 22:35 UTC.",
                Start = new DateTime(2012, 2, 21),
                End = new DateTime(2012, 2, 21),
                Type = EventType.NewMoon
            });
            
            Events.Add(new AstronomyEvent()
            {
                Description = "The red planet will be at its closest approach to Earth and its face will be fully illuminated by the Sun. This is the best time to view and photograph Mars.",
                Start = new DateTime(2012, 3, 3),
                End = new DateTime(2012, 3, 3),
                Type = EventType.NewMoon
            });
            
            Events.Add(new AstronomyEvent()
            {
                Description = "The Moon will be directly opposite the Earth from the Sun and will be fully illuminated as seen from Earth. This phase occurs at 09:39 UTC.",
                Start = new DateTime(2012, 3, 8),
                End = new DateTime(2012, 3, 8),
                Type = EventType.NewMoon
            });
            
            DeSerialize();
            
        }
        #endregion
        
        #region Properties
        public ObservableCollection<AstronomyEvent> Events { get; set; }
        #endregion
        
        #region Methods
        public void AddEvent()
        {

            AstronomyEvent l_NewAE = new AstronomyEvent();
            
            UserControls.NewAstronomyEvent l_NAE = new UserControls.NewAstronomyEvent();
            l_NAE.DataContext = l_NewAE;
            
            bool? l_Result = l_NAE.ShowDialog();
            
            if (l_Result.HasValue && l_Result.Value)
                Events.Add(l_NewAE);
            
        }
        public void Serialize()
        {

        }
        
        private void DeSerialize()
        {
            
        }
        #endregion
        
    }
    
}